<?php

/**
 * This is the model class for table "personnel_technique".
 *
 * The followings are the available columns in table 'personnel_technique':
 * @property integer $ID_PERSONNEL_TECHNIQUE
 * @property string $NOM_PERSONNEL
 * @property string $PRENOM_PERSONNEL
 * @property string $MAIL_PERSONNEL
 * @property string $FONCTION_PERSONNEL
 * @property string $LOGIN_PERSONNEL
 * @property string $PASSWORD_PERSONNEL
 *
 * The followings are the available model relations:
 * @property Affectation[] $affectations
 * @property CompetencesPbLogiciel[] $competencesPbLogiciels
 * @property CompetencesPbMateriel[] $competencesPbMateriels
 * @property InterventionsRealisees[] $interventionsRealisees
 */
class PersonnelTechnique extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return PersonnelTechnique the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'personnel_technique';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('NOM_PERSONNEL, PRENOM_PERSONNEL, MAIL_PERSONNEL, FONCTION_PERSONNEL, LOGIN_PERSONNEL, PASSWORD_PERSONNEL', 'required'),
			array('NOM_PERSONNEL, PRENOM_PERSONNEL, FONCTION_PERSONNEL, LOGIN_PERSONNEL, PASSWORD_PERSONNEL', 'length', 'max'=>50),
			array('MAIL_PERSONNEL', 'length', 'max'=>60),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('ID_PERSONNEL_TECHNIQUE, NOM_PERSONNEL, PRENOM_PERSONNEL, MAIL_PERSONNEL, FONCTION_PERSONNEL, LOGIN_PERSONNEL, PASSWORD_PERSONNEL', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'affectations' => array(self::HAS_MANY, 'Affectation', 'ID_PERSONNEL_TECHNIQUE'),
			'competencesPbLogiciels' => array(self::HAS_MANY, 'CompetencesPbLogiciel', 'ID_PERSONNEL_TECHNIQUE'),
			'competencesPbMateriels' => array(self::HAS_MANY, 'CompetencesPbMateriel', 'ID_PERSONNEL_TECHNIQUE'),
			'interventionsRealisees' => array(self::HAS_MANY, 'InterventionsRealisees', 'ID_PERSONNEL_TECHNIQUE'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'ID_PERSONNEL_TECHNIQUE' => 'Id Personnel Technique',
			'NOM_PERSONNEL' => 'Nom Personnel',
			'PRENOM_PERSONNEL' => 'Prenom Personnel',
			'MAIL_PERSONNEL' => 'Mail Personnel',
			'FONCTION_PERSONNEL' => 'Fonction Personnel',
			'LOGIN_PERSONNEL' => 'Login Personnel',
			'PASSWORD_PERSONNEL' => 'Password Personnel',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('ID_PERSONNEL_TECHNIQUE',$this->ID_PERSONNEL_TECHNIQUE);
		$criteria->compare('NOM_PERSONNEL',$this->NOM_PERSONNEL,true);
		$criteria->compare('PRENOM_PERSONNEL',$this->PRENOM_PERSONNEL,true);
		$criteria->compare('MAIL_PERSONNEL',$this->MAIL_PERSONNEL,true);
		$criteria->compare('FONCTION_PERSONNEL',$this->FONCTION_PERSONNEL,true);
		$criteria->compare('LOGIN_PERSONNEL',$this->LOGIN_PERSONNEL,true);
		$criteria->compare('PASSWORD_PERSONNEL',$this->PASSWORD_PERSONNEL,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}